import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import executor.Entity.*;
import executor.XxlJobExecutorApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Arrays;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = XxlJobExecutorApplication.class)
public class JSONDemo {

    @Test
    public void test(){
        String list="{\"data\":{\"id\":\"b74bdf7ac11499935ac3fa4e019fb98d\",\"type\":\"users\",\"attributes\":{\"nickname\":\"huyuan\",\"email\":\"huyuan@tiduyun.cn\",\"gavatar\":\"https://avatar-alioss.tower.im/letter_avatars/b74bdf7ac11499935ac3fa4e019fb98d_huyuan\",\"created_at\":\"2020-05-08T10:30:34.000+08:00\",\"updated_at\":\"2020-06-03T09:57:55.000+08:00\"}},\"jsonapi\":{\"version\":\"1.0\"}}";
//        List<Object> dataList = Arrays.asList(JSON.parseArray(list).toArray());
        JSONObject dataList = JSON.parseObject(list);
        Object data = dataList.get("data");
        System.out.println(data);
        JSONObject jsonObject = (JSONObject) JSON.parseObject(String.valueOf(data));

        Object attributes = jsonObject.get("attributes");
        System.out.println(attributes);

        JsonDataVO jsonDataVO = JSON.parseObject(String.valueOf(data), JsonDataVO.class);
        System.out.println(jsonDataVO);

        AttributesVO attributesVO = JSON.parseObject(String.valueOf(attributes), AttributesVO.class);
        System.out.println(attributesVO);

        Id id = JSON.parseObject(String.valueOf(data),Id.class);
        System.out.println(id);

        Email email = JSON.parseObject(String.valueOf(attributes),Email.class);
        System.out.println(email);
//        List<AttributesVO> AttributesVO = JSONObject.parseArray(dataList,AttributesVO.class);


//        JSONObject dataList = new JSONObject(list);
//                List<String> dataList = JSON.parseArray(list).toJavaList(String.class);

        System.out.println(dataList);
    }
}
